package com.vic.bean;

import com.vic.Utils.dbutils;

/**
 * @Author: Vic Ly
 * 设置常量信息用于读取配置
 */
public class constant {
    // 作者名字
    public static  String AUTHOR_CLAZZ;
    // 是否忽略表前缀
    public static Boolean IGNORE_TABLE_PREFIX;
    // 设置参数bean的后缀
    public static String SUFFIX_BEAN_QUERY;
    // 参数模糊搜索后缀
    public static String SUFFIX_BEAN_QUERY_FUZZY;
    // 参数日期起止
    public static String SUFFIX_BEAN_QUERY_TIME_START;

    // Mapper/Dao接口后缀
    public static String SUFFIX_MAPPER;

    public static String SUFFIX_BEAN_QUERY_TIME_END;
    // 辅助目录(用于源代码路径)
    public static String BASE_JAVA = "java";
    // 辅助目录(用于资源路径)
    public static String BASE_RESOURCE = "resources";
    // 文件生成基础路径
    public static String BASE_PATH;
    // 基础包名
    public static String BASE_PACKAGE;

    // 实体类路径(全路径)(D:/utils/myUtils-easyJava/easyJava-Test/src/main/java/com/vic/entity)
    public static String PATH_PO;

    // 实体类类路径(例如：com.vic.entity)
    public static String PACKAGE_PO;

    // 参数包bean -> Query
    public static String QUERY_PACKAGE;

    // 参数路径
    public static String QUERY_PATH;

    // 公共Query
    public static String GLOBAL_QUERY_PACKAGE;
    public static String GLOBAL_QUERY_PATH;

    // vo
    public static String VO_PACKAGE;
    public static String VO_PATH;


    // base mapper
    public static String MAPPER_BASE_PACKAGE;
    public static String MAPPER_BASE_PATH;
    // mapper
    public static String MAPPER_PACKAGE;

    // mapper全路径
    public static String MAPPER_PATH;

    // service
    public static String SERVICE_PACKAGE;
    public static String SERVICE_IMPL_PACKAGE;

    public static String SERVICE_PATH;
    public static String SERVICE_IMPL_PATH;

    // controller
    public static String CONTROLLER_PACKAGE;
    public static String CONTROLLER_PATH;

    // 存放公共controller
    public static String GLOBAL_CONTROLLER_PACKAGE;
    public static String GLOBAL_CONTROLLER_PATH;

    // 工具包类路径
    public static String UTILS_PACKAGE;

    // 工具包全路径
    public static String UTILS_PATH;

    // 日期格式枚举类路径
    public static String ENUMS_PACKAGE;

    // 日期格式枚举全路径
    public static String ENUMS_PATH;

    // 异常包
    public static String EXCEPTION_PACKAGE;
    public static String EXCEPTION_PATH;

    // 用于存放其他的参数或者三方类等
    public static  String OTHER_PACKAGE;
    public static  String OTHER_PATH;

    // mapper接口的xml文件生成路径
    public static  String MAPPER_XML_PATH;

    // 修饰符
    public static String ACCESS_PRIVATE;

    // 需要忽略的属性（@JsonIgnore：从上到下依次为 注解生效的位置/字段,注解设置,注解所在包）
    public static String IGNORE_BEAN_ToJSON_FIELD;
    public static String IGNORE_BEAN_ToJSON_FIELD_EXPRESSION;
    public static String IGNORE_BEAN_ToJSON_CLASS;

    // 日期改格式序列化
    public static String BEAN_DATE_FORMAT_EXPRESSION;
    public static String BEAN_DATE_FORMAT_CLASS;
    // 日期格式反序列化
    public static String BEAN_DATE_UnFORMAT_EXPRESSION;
    public static String BEAN_DATE_UnFORMAT_CLASS;

    static {
        AUTHOR_CLAZZ = dbutils.getString("author.clazz");

        IGNORE_TABLE_PREFIX = Boolean.parseBoolean(dbutils.getString("ignore.table.prefix"));

        SUFFIX_BEAN_QUERY = dbutils.getString("suffix.bean.query");
        SUFFIX_BEAN_QUERY_FUZZY = dbutils.getString("suffix.bean.query.fuzzy");
        SUFFIX_BEAN_QUERY_TIME_START = dbutils.getString("suffix.bean.query.time.start");
        SUFFIX_BEAN_QUERY_TIME_END = dbutils.getString("suffix.bean.query.time.end");
        SUFFIX_MAPPER = dbutils.getString("suffix.mapper");


        BASE_PACKAGE = dbutils.getString("base.package");
        // po
        PACKAGE_PO = BASE_PACKAGE +"."+ dbutils.getString("pojo.package");
        QUERY_PACKAGE = BASE_PACKAGE +"."+ dbutils.getString("query.package");
        GLOBAL_QUERY_PACKAGE = BASE_PACKAGE +"."+ dbutils.getString("global.query.package");
        VO_PACKAGE = BASE_PACKAGE +"."+ dbutils.getString("vo.package");
        MAPPER_PACKAGE = BASE_PACKAGE +"."+ dbutils.getString("mapper.package");
        MAPPER_BASE_PACKAGE = BASE_PACKAGE +"."+ dbutils.getString("mapper.base.package");
        CONTROLLER_PACKAGE = BASE_PACKAGE +"."+ dbutils.getString("controller.package");
        GLOBAL_CONTROLLER_PACKAGE = BASE_PACKAGE +"."+dbutils.getString("global.controller.package");
        SERVICE_PACKAGE = BASE_PACKAGE +"."+ dbutils.getString("service.package");
        SERVICE_IMPL_PACKAGE = BASE_PACKAGE +"."+ dbutils.getString("service.Impl.package");

        UTILS_PACKAGE = BASE_PACKAGE + "." + dbutils.getString("utils.package");
        ENUMS_PACKAGE = BASE_PACKAGE + "." + dbutils.getString("enums.package");
        EXCEPTION_PACKAGE = BASE_PACKAGE + "." + dbutils.getString("exception.package");
        OTHER_PACKAGE = BASE_PACKAGE + "." + dbutils.getString("other.package");

        BASE_PATH = dbutils.getString("base.path");
        BASE_PATH = BASE_PATH +"/"+BASE_JAVA;
        PATH_PO = BASE_PATH + "/"+ PACKAGE_PO.replace(".","/");
        QUERY_PATH = BASE_PATH + "/"+ QUERY_PACKAGE.replace(".","/");
        GLOBAL_QUERY_PATH = BASE_PATH + "/"+ GLOBAL_QUERY_PACKAGE.replace(".","/");
        VO_PATH = BASE_PATH + "/"+ VO_PACKAGE.replace(".","/");
        MAPPER_PATH = BASE_PATH + "/"+ MAPPER_PACKAGE.replace(".","/");
        MAPPER_BASE_PATH = BASE_PATH + "/"+ MAPPER_BASE_PACKAGE.replace(".","/");
        CONTROLLER_PATH = BASE_PATH + "/"+ CONTROLLER_PACKAGE.replace(".","/");
        GLOBAL_CONTROLLER_PATH = BASE_PATH + "/"+ GLOBAL_CONTROLLER_PACKAGE.replace(".","/");
        SERVICE_PATH = BASE_PATH + "/"+ SERVICE_PACKAGE.replace(".","/");
        SERVICE_IMPL_PATH = BASE_PATH + "/"+ SERVICE_IMPL_PACKAGE.replace(".","/");


        UTILS_PATH = BASE_PATH + "/"+UTILS_PACKAGE.replace(".","/");
        ENUMS_PATH = BASE_PATH + "/"+ENUMS_PACKAGE.replace(".","/");
        EXCEPTION_PATH = BASE_PATH + "/"+EXCEPTION_PACKAGE.replace(".","/");
        OTHER_PATH = BASE_PATH + "/"+OTHER_PACKAGE.replace(".","/");

        ACCESS_PRIVATE = dbutils.getString("access.private");

        IGNORE_BEAN_ToJSON_FIELD = dbutils.getString("ignore.bean.toJson.field");
        IGNORE_BEAN_ToJSON_FIELD_EXPRESSION = dbutils.getString("ignore.bean.toJson.field.expression");
        IGNORE_BEAN_ToJSON_CLASS = dbutils.getString("ignore.bean.toJson.class");

        BEAN_DATE_FORMAT_EXPRESSION = dbutils.getString("bean.date.format.expression");
        BEAN_DATE_FORMAT_CLASS = dbutils.getString("bean.date.format.class");

        BEAN_DATE_UnFORMAT_EXPRESSION = dbutils.getString("bean.date.unformat.expression");
        BEAN_DATE_UnFORMAT_CLASS = dbutils.getString("bean.date.unformat.class");

        MAPPER_XML_PATH = dbutils.getString("base.path") + "/"+ BASE_RESOURCE+ "/" + dbutils.getString("mapper.package");


    }

    // 类型常量，用于类型转换
    public final static String[] SQL_DATE_TIME = new String[]{"datetime","timestamp"};
    public final static String[] SQL_DATE = new String[]{"date"};
    public final static String[] SQL_DECIMAL = new String[]{"decimal","double","float"};
    public final static String[] SQL_STRING = new String[]{"char","varchar"};
    public final static String[] SQL_INTEGER = new String[]{"int","tinyint"};
    public final static String[] SQL_LONG = new String[]{"bigint"};

    public static void main(String[] args) {
//        System.out.println("base_path ： "+BASE_PATH);
//        System.out.println("path_po ： "+PATH_PO);
//        System.out.println("base_path ： "+BASE_PATH);
//        System.out.println("base_package ： "+BASE_PACKAGE);
//        System.out.println("package_po ： "+PACKAGE_PO);
//        System.out.println(ACCESS_PRIVATE);
//        System.out.println(IGNORE_BEAN_ToJSON_FIELD);
//        System.out.println(IGNORE_BEAN_ToJSON_FIELD_EXPRESSION);
//        System.out.println(IGNORE_BEAN_ToJSON_CLASS);
//        System.out.println(BEAN_DATE_FORMAT_EXPRESSION);
//        System.out.println(BEAN_DATE_FORMAT_CLASS);
//        System.out.println(BEAN_DATE_UnFORMAT_EXPRESSION);
//        System.out.println(BEAN_DATE_UnFORMAT_CLASS);
//        System.out.println(UTILS_PACKAGE);
//        System.out.println(PATH_PO);
//        System.out.println(UTILS_PATH);
//        System.out.println(SUFFIX_BEAN_QUERY_FUZZY);
//        System.out.println(MAPPER_BASE_PACKAGE);
//        System.out.println(MAPPER_PACKAGE);
//        System.out.println(MAPPER_XML_PATH);
        System.out.println("p1 = "+SERVICE_PACKAGE);
        System.out.println("p2 = "+SERVICE_IMPL_PACKAGE);
        System.out.println("p3 = "+SERVICE_PATH);
        System.out.println("p4 = "+SERVICE_IMPL_PATH);
        System.out.println("v1 = "+VO_PACKAGE);
        System.out.println("v2 = "+VO_PATH);
        System.out.println("g1 = "+GLOBAL_CONTROLLER_PACKAGE);
        System.out.println("g1 = "+GLOBAL_CONTROLLER_PATH);
        System.out.println("o1 = "+OTHER_PACKAGE);
        System.out.println("o2 = "+OTHER_PATH);
        System.out.println("gq1 = "+GLOBAL_QUERY_PACKAGE);
        System.out.println("gq2 = "+GLOBAL_QUERY_PATH);

    }


}
